<template>
	<view class="my">
		<view class="u-flex header" @click="goMyInfo" v-if="obj">
			<view class="h-img">
				<!-- <u-avatar :src="obj.headImg" size="140"></u-avatar> -->
				<open-data type="userAvatarUrl" :default-avatar="obj.headImg"></open-data>
			</view>

			<view class="u-flex-1 h-info">
				<view class="h-phone">{{obj.phone | hphone}}</view>
				<view class="h-role">{{lrole.roleName}}V3.42</view>
				<!-- <u-icon class="h-role" width="160" height="40" name="/static/icons/lrole-driver.png"></u-icon> -->
			</view>

			<view class="h-edit-btn">
				<u-icon name="/static/icons/edit.png" width="28" height="28"></u-icon>
			</view>
		</view>

		<view class="banner-imgs">
			<u-swiper :list="bannerList" :interval="60000" mode="none" :effect3d="false"
				:img-mode="'scaleToFill'"></u-swiper>
		</view>

		<view class="grid-menu">
			<u-grid :col="4" :border="false">
				<u-grid-item @click="gotoAllBzList">
					<u-icon :name="`${staticUrl}/grid/jzbx.png`" width="80" height="80"></u-icon>
					<view class="grid-text">记账报销</view>
				</u-grid-item>

				<u-grid-item @click="gotoQjList" v-if="lrole.roleName == '驾驶员'">
					<u-icon :name="`${staticUrl}/grid/qjxx.png`" width="80" height="80"></u-icon>
					<view class="grid-text">请假休息</view>
				</u-grid-item>
				<u-grid-item @click="gotoQjList2" v-if="lrole.roleName != '驾驶员'">
					<u-icon :name="`${staticUrl}/grid/qjxx.png`" width="80" height="80"></u-icon>
					<view class="grid-text">请假休息</view>
				</u-grid-item>
				<u-grid-item @click="wallet">
					<u-icon :name="`${staticUrl}/grid/wallet.png`" width="80" height="80"></u-icon>
					<view class="grid-text">钱包管理</view>
				</u-grid-item>
				<u-grid-item @click="pdsDetail">
					<u-icon :name="`${staticUrl}/grid/pdsDetail.png`" width="80" height="80"></u-icon>
					<view class="grid-text">奖惩规则</view>
				</u-grid-item>


				<!-- <u-grid-item @click="gotoRouteTrackList">
					<u-icon :name="`${staticUrl}/grid/wdgj.png`" width="80" height="80"></u-icon>
					<view class="grid-text">行程轨迹</view>
				</u-grid-item> -->

				<!-- <u-grid-item @click="goBindWx">
					<u-icon :name="`${staticUrl}/grid/wxbd.png`" width="80" height="80"></u-icon>
					<view class="grid-text">绑定微信小程序无法绑定公众号微信</view>
				</u-grid-item> -->
			</u-grid>
			<u-grid :col="4" :border="false">
				<u-grid-item  v-if="lrole.roleName == '驾驶员'" @click="violations_and_accidents_btn">
					<u-icon :name="`${staticUrl}/grid/dtlb.png`" width="80" height="120"></u-icon>
					<view class="grid-text" style="margin-top: 20rpx;">违章与事故</view>
				</u-grid-item>
				<u-grid-item  v-if="lrole.roleName != '驾驶员'" @click="violations_and_accidents_btn2">
					<u-icon :name="`${staticUrl}/grid/dtlb.png`" width="80" height="120"></u-icon>
					<view class="grid-text" style="margin-top: 20rpx;">违章与事故</view>
				</u-grid-item>
				<u-grid-item @click="wx_btn">
					<u-icon :name="`${staticUrl}/grid/wx.png`" width="80" height="80"></u-icon>
					<view class="grid-text">修理厂</view>
				</u-grid-item>
				<u-grid-item v-if="lrole.roleName != '驾驶员'" @click="dynamic_list_btn">
					<u-icon :name="`${staticUrl}/grid/wzsg.png`" width="80" height="80"></u-icon>
					<view class="grid-text">动态列表</view>
				</u-grid-item>
				<u-grid-item v-if="lrole.roleName != '驾驶员'" @click="flightTrainInfo_list_btn">
					<u-icon :name="`${staticUrl}/grid/flightTrainInfo.png`" width="80" height="80"></u-icon>
					<view class="grid-text">航班车次列表</view>
				</u-grid-item>
			</u-grid>
			<u-grid :col="4" :border="false">
				<u-grid-item v-if="lrole.roleName != '驾驶员'" @click="jsy_list_btn">
					<u-icon :name="`${staticUrl}/grid/jsy.png`" width="80" height="80"></u-icon>
					<view class="grid-text">驾驶员报账</view>
				</u-grid-item>
				<u-grid-item v-if="lrole.roleName != '驾驶员'" @click="yh_list_btn">
					<u-icon :name="`${staticUrl}/grid/yh.png`" width="80" height="80"></u-icon>
					<view class="grid-text">银行流水</view>
				</u-grid-item>
				<u-grid-item v-if="lrole.roleName != '驾驶员'" @click="TravelAdviceFollowList_btn">
					<u-icon :name="`${staticUrl}/grid/zixun.png`" width="80" height="80"></u-icon>
					<view class="grid-text">包车咨询回访</view>
				</u-grid-item>
				<u-grid-item v-if="lrole.roleName != '驾驶员'" @click="my_car_btn">
					<u-icon style="margin-top: 15rpx;" :name="`${staticUrl}/grid/my_car.png`" width="80"
						height="80"></u-icon>
					<view class="grid-text">我的车辆</view>
				</u-grid-item>

			</u-grid>
			<u-grid :col="4" :border="false">
				<u-grid-item v-if="lrole.roleName != '驾驶员'" @click="sumCusGathPay_btn">
					<u-icon style="margin-top: 15rpx;" :name="`${staticUrl}/grid/sumCusGathPay.png`" width="80"
						height="80"></u-icon>
					<view class="grid-text">应收应支</view>
				</u-grid-item>
				<u-grid-item v-if="lrole.roleName != '驾驶员'" @click="gongzi_btn">
					<u-icon style="margin-top: 15rpx;" :name="`${staticUrl}/grid/gongzi.png`" width="80"
						height="80"></u-icon>
					<view class="grid-text">工资明细</view>
				</u-grid-item>
			</u-grid>
			<!-- <u-button @click="out_login" type="primary" >退出登录</u-button> -->
		</view>
		<u-tabbar :list="tabbar"></u-tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				lrole: {},
				tabbar: '',
				staticUrl: this.C.staticNetUrl,
				// 登录信息
				obj: null,
				// banner图片列表
				bannerList: [{
						image: `${this.C.staticNetUrl}/banner1.png`,
						title: '优惠券'
					},
					{
						image: 'https://cdn.uviewui.com/uview/swiper/3.jpg',
						title: '谁念西风独自凉，萧萧黄叶闭疏窗，沉思往事立残阳'
					}
				],
			}
		},
		onLoad() {
			console.log(this.C.staticNetUrl + '/grid/pdsDetail.png')
			let lrole = uni.getStorageSync('lrole');
			this.lrole = lrole
			if (lrole.roleName == '驾驶员') {
				this.tabbar = [{
						iconPath: "/static/tabbar/order.png",
						selectedIconPath: "/static/tabbar/order-sel.png",
						text: '订单',
						isDot: false,
						pagePath: "/pages/tabbar/order-list/order-list"
					},
					{
						iconPath: "/static/tabbar/bz.png",
						selectedIconPath: "/static/tabbar/bz-sel.png",
						text: '报账',
						isDot: false,
						pagePath: "/pages/tabbar/order-bz-list/order-bz-list"
					}, {
						iconPath: "/static/tabbar/user.png",
						selectedIconPath: "/static/tabbar/user-sel.png",
						text: '我的',
						isDot: false,
						pagePath: "/pages/tabbar/my/my"
					}
				]
			} else {
				this.tabbar = [{
						iconPath: "/static/tabbar/order.png",
						selectedIconPath: "/static/tabbar/order-sel.png",
						text: '订单',
						isDot: false,
						pagePath: "/pages/tabbar/order-list/order-list"
					},
					{
						iconPath: "/static/tabbar/notice.png",
						selectedIconPath: "/static/tabbar/bz-sel.png",
						text: '抢单',
						isDot: false,
						pagePath: "/pages/tabbar/my-notice/my-notice"
					},
					{
						iconPath: "/static/tabbar/bz.png",
						selectedIconPath: "/static/tabbar/notice-sel.png",
						text: '报账',
						isDot: false,
						pagePath: "/pages/tabbar/order-bz-list/order-bz-list"
					}, {
						iconPath: "/static/tabbar/user.png",
						selectedIconPath: "/static/tabbar/user-sel.png",
						text: '我的',
						isDot: false,
						pagePath: "/pages/tabbar/my/my"
					}
				]
			}
			const that = this;

			// 设置-导航栏标题为车队名称
			uni.setNavigationBarTitle({
				title: '遇见巴士'
			});

			that.getLuserInfo();
		},
		onShow() {


		},
		methods: {
			/** 获取-登录用户信息 */
			getLuserInfo() {
				const that = this,
					U = that.U;

				that.obj = uni.getStorageSync(that.C.luser);


				// that.$u.api.getLuserInfo({}).then(res => {
				// 	if (res.code != 1) {
				// 		U.qerror(res.msg);
				// 	} else {
				// 		// console.log('登录信息ss', res);
				// 		that.obj = res.data;
				// 		console.log('最终信息', that.obj);
				// 	}
				// });
			},
			// 导航-个人资料
			goMyInfo() {
				uni.navigateTo({
					url: '/my-man/my-info/my-info'
				});
			},
			// 导航-绑定微信
			goBindWx() {
				uni.navigateTo({
					url: '/my-man/bind-wx/bind-wx'
				});
			},
			// 导航-请假列表
			gotoQjList() {
				uni.navigateTo({
					url: '/my-man/qj-list/qj-list'
				});
			},
			// 导航-请假列表
			gotoQjList2() {
				uni.navigateTo({
					url: '/my-man/qj-list2/qj-list2'
				});
			},
			// 钱包管理
			wallet() {
				uni.navigateTo({
					url: '/my-man/wallet/wallet'
				});
			},
			// 奖惩规则
			pdsDetail() {
				uni.navigateTo({
					url: '/my-man/pdsDetail/pdsDetail'
				});
			},
			violations_and_accidents_btn() {
				uni.navigateTo({
					url: '/my-man/violations_and_accidents/violations_and_accidents'
				});
			},
			violations_and_accidents_btn2() {
				uni.navigateTo({
					url: '/my-man/violations_and_accidents2/violations_and_accidents2'
				});
			},
			
			

			// 维修厂列表
			wx_btn() {
				uni.navigateTo({
					url: '/my-man/maintenance_shop/maintenance_shop'
				});
			},
			// 动态列表
			dynamic_list_btn() {
				uni.navigateTo({
					url: '/my-man/dynamic_list/dynamic_list'
				});
			},
			flightTrainInfo_list_btn() {
				uni.navigateTo({
					url: '/my-man/flightTrainInfo_list/flightTrainInfo_list'
				});
			},
			jsy_list_btn() {
				uni.navigateTo({
					url: '/my-man/jsy_list/jsy_list'
				});
			},
			yh_list_btn() {
				uni.navigateTo({
					url: '/my-man/yh_list/yh_list'
				});
			},
			// 导航-咨询回访列表
			TravelAdviceFollowList_btn() {
				uni.navigateTo({
					url: '/my-man/TravelAdviceFollowList/TravelAdviceFollowList'
				});
			},
			// 我的车辆
			my_car_btn() {
				uni.navigateTo({
					url: '/my-man/my_car/my_car'
				});
			},
			// 应收应支
			sumCusGathPay_btn() {
				uni.navigateTo({
					url: '/my-man/sumCusGathPay/sumCusGathPay'
				});
			},
			// 工资明细
			gongzi_btn() {
				uni.navigateTo({
					url: '/my-man/gongzi/gongzi'
				});
			},

			// 导航-行程轨迹列表
			gotoRouteTrackList() {
				uni.navigateTo({
					url: '/my-man/route-track-list/route-track/route-track'
				});
			},
			// 导航-全部记账列表
			gotoAllBzList() {
				uni.navigateTo({
					url: '/bz-man/all-bz-list/all-bz-list'
				});
			},

			out_login() {
				const that = this,
					U = that.U;
				that.$u.api.logout().then(loginres => {
					if (loginres.code == 1) {
						// 清空缓存
						uni.setStorageSync(that.C.uuid, '');

						uni.reLaunch({
							url: '/pages/common/index/index'
						})
					} else {

						U.qerror(loginres.msg);
						uni.setStorageSync(that.C.uuid, '');

						uni.reLaunch({
							url: '/pages/common/index/index'
						})
					}
				});
			},
		}
	}
</script>

<style lang="less">
	.my {
		height: 100vh;
		background: #fbf9f9;

		.header {
			background: #fff;
			padding: 70rpx 0px 52rpx 50rpx;
			height: 240rpx;

			.h-img {
				margin-right: 50rpx;
				overflow: hidden;
				display: block;
				width: 160rpx;
				height: 160rpx;
				margin: 20rpx;
				border-radius: 50%;
				border: 4rpx solid #fff;
				box-shadow: 6rpx 6rpx 20rpx rgba(0, 0, 0, 0.2);
			}

			.h-info {

				.h-phone {
					font-size: 36rpx;
					font-weight: 500;
				}

				.h-role {
					font-weight: 700;
					text-align: center;
					width: 200rpx;
					height: 50rpx;
					color: #ff2292;
					line-height: 50rpx;
					border-radius: 10rpx;
					background-color: aqua;
					margin-top: 10rpx;
				}
			}

			.h-edit-btn {
				margin-right: 40rpx;
			}
		}

		.banner-imgs {
			padding: 20rpx 20rpx 30rpx 20rpx;
		}

		.grid-menu {
			margin: 0rpx 10rpx;
			background: #fff;

			.grid-text {
				font-size: 24rpx;
			}
		}
	}
</style>